package com.csun.cmny.provider.device.watch.entity;

    /// <summary>
    ///  上行终端数据包
    ///  关联下行确认 034
    ///  Uplink terminal number information packet
    ///  Associated downlink confirmation 034
    /// </summary>
    public class C033
    {
        /// <summary>
        /// 数据起封包 @B#@ 
        /// Start Fixed value :@B#@ 
        /// </summary>
        public String HeadCode = "@B#@";
        /// <summary>
        /// 协议版本号
        /// Protocol version number
        /// </summary>
        public String Protocol = null;
        /// <summary>
        /// 功能代码识别
        /// Function code
        /// </summary>
        public final String FunCode = "033";
        /// <summary>
        /// 国际移动设备身份码
        /// International Mobile Equipment Identity
        /// </summary>
        public String IMEI = null;
        /// <summary>
        /// 国际移动用户识别码
        /// International Mobile Subscriber Identification Number
        /// </summary>
        public String IMSI = null;
        /// <summary>
        /// 佩戴状态 （0:未佩戴 ;1:已佩戴）
        /// Terminal wear state  (0: is not worn; 1: is worn)
        /// </summary>
        public int WearState = 0;
        /// <summary>
        /// 剩余电量百分比（range:1-100）
        /// Percentage of residual electricity (range:1-100)
        /// </summary>
        public int Power = 0;
         /// <summary>
         /// 终端当前时间(年月日时分秒) yyyyMMddHHmmss
         /// The terminal current time ( format:yyyyMMddHHmmss)
          /// </summary>
        public String TerminalTime = null;
        /// <summary>
        /// 结尾封包 @E#@
        /// End packet @E#@
        /// </summary>
        public String FootCode = "@E#@";



        /// <summary>
        /// 初始化模型
        ///@B#@|01|033|111112222233333|8888888888888888|1|52|20160715162720|@E#@
        /// </summary>
        /// <param name="cmdStr">命令代码</param>
        public C033(String cmdStr)
        {
        	String[] data = cmdStr.split("\\|");
            int dataLength = data.length;
            if (dataLength == 9 && "@B#@".equals(data[0]) && FunCode.equals(data[2]))
            {
                HeadCode = data[0];
                Protocol = data[1];
                IMEI = data[3];
                IMSI = data[4];
                WearState = Integer.parseInt(data[5]);
                Power = Integer.parseInt(data[6]);
                TerminalTime = data[7];
                FootCode = data[8];
            }

        }

        public  String ToString()
        {
        	String rString = HeadCode + "|";
            rString += Protocol + "|";
            rString += FunCode + "|";
            rString += IMEI + "|";
            rString += IMSI + "|";
            rString += WearState + "|";
            rString += Power + "|";
            rString += TerminalTime + "|";
            rString += FootCode;
            return rString;
        }
    }




